
export const noop = () => {};

export const clone = (data) => {
	if (typeof data === 'object') return JSON.parse(JSON.stringify(data));
	return data;
}

export const delayWith = (payLoad, delayTime) => {
	return new Promise((resolve) => setTimeout(() => resolve(payLoad), +delayTime || 1000) )
}

// 获取src/assets/images目录中的图片
export const getAssetsImage = (url) => {
    return new URL(`../assets/images/${url}`, import.meta.url).href
}

// 获取/public/img目录中的图片
export const getPublicImage = (url) => {
    return new URL(`/img/${url}`, import.meta.url).href
}

// 获取后端请求路径
export const getServerUrl = (url) => {
    return '//' + (__SERVER_ADDRESS__ + (url ? '/' + url : '')).replace(/\/{2,}/, '/');
}